/**
 * @author wangmao
 * @date 2021/11/8 11:33
 */
/// <reference path="validation.ts"/>
var Validation;
(function (Validation) {
    var lettersRegexp = /^[A-Za-z]+$/;
    var LettersOnlyValidator = /** @class */ (function () {
        function LettersOnlyValidator() {
        }
        LettersOnlyValidator.prototype.isAcceptable = function (s) {
            return lettersRegexp.test(s);
        };
        return LettersOnlyValidator;
    }());
    Validation.LettersOnlyValidator = LettersOnlyValidator;
    var WorldOnlyValidator = /** @class */ (function () {
        function WorldOnlyValidator() {
        }
        WorldOnlyValidator.prototype.isAcceptable = function (s) {
            return lettersRegexp.test(s);
        };
        return WorldOnlyValidator;
    }());
})(Validation || (Validation = {}));
/**
 * @author wangmao
 * @date 2021/11/8 11:37
 */
/// <reference path="Validation.ts"/>
var Validation;
(function (Validation) {
    var numberRegexp = /^[0-9]+$/;
    var ZipCodeValidation = /** @class */ (function () {
        function ZipCodeValidation() {
        }
        ZipCodeValidation.prototype.isAcceptable = function (s) {
            return s.length === 5 && numberRegexp.test(s);
        };
        return ZipCodeValidation;
    }());
    Validation.ZipCodeValidation = ZipCodeValidation;
})(Validation || (Validation = {}));
/**
 * @author wangmao
 * @date 2021/11/8 10:01
 */
/*  我们可以使用typeof关键字。 typeof关键字，当在表示类型的地方使用时，会得出一个类型值，这里就表示模块的类型。
// 等同于  myValidator:Validator = new Validator()
let myValidator:typeof Validator
console.log(myValidator); */
/// <reference path="Validation.ts" />
/// <reference path="LettersOnlyValidator.ts" />
/// <reference path="ZipCodeValidator.ts" />
// Some samples to try
var strings = ["Hello", "98052", "101"];
// Validators to use
var validators = {};
validators["ZIP code"] = new Validation.ZipCodeValidation();
validators["Letters only"] = new Validation.LettersOnlyValidator();
// Show whether each string passed each validator
for (var _i = 0, strings_1 = strings; _i < strings_1.length; _i++) {
    var s = strings_1[_i];
    for (var name_1 in validators) {
        console.log("\"" + s + "\" - " + (validators[name_1].isAcceptable(s) ? "matches" : "does not match") + " " + name_1);
    }
}
